package com.veo;

import org.springframework.core.convert.converter.Converter;
import org.springframework.util.StringUtils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class ConvertStringToDate implements Converter<String, Date> {
    public Date convert(String s) {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        if (StringUtils.hasLength(s)){
            try {
                Date parse = format.parse(s);
                return parse;
            } catch (ParseException e) {
                e.printStackTrace();
            }
        }

        return null;
    }
}
